<script type="text/javascript" src="<?php echo RESOURCE_PATH;?>/js/jquery.validation.min.js"></script>
<script type="text/javascript" src="<?php echo TEMPLATES_PATH;?>/js/common_select.js" charset="utf-8"></script>
<script type="text/javascript" src="<?php echo TEMPLATES_PATH;?>/js/area_array.js" charset="utf-8"></script>

<header class="layout head padding-small">
    <a href="javascript:back(true);" class="hBack float-left"></a>
    <h4 class="hTxt float-left text-center text-white"><?php if($output['addr_edit']!=1) {echo '添加';}else {echo '修改';}?>收货人信息</h4>
    <a href="javascript:;" id="btnJdkey" class="hHlep float-right"></a>
</header>
<!--添加、修改收货地址S-->
<form id="addr_form"  method="get">
    <input type="hidden" name="act" value="member_index" >
    <input type="hidden" name="op" value="address_mod">
    <input type="hidden" name="form_submit" value="ok">
    <input type="hidden" name="id" value="<?php echo $output['address']['address_id'];?>">
    <div class="add-con margin bg-white padding height radius-big">
        <div class="padding-small-top"><span class="text-red">*</span>收货人
            <div class="border border-ef7f7e padding radius-big "><input type="text" class="border-none layout"  name="true_name" value="<?php echo $output['address']['true_name'];?>" id="true_name" maxlength="10"></div>
        </div>
        <div class="padding-small-top"><span class="text-red">*</span>手机号码
            <div class="border border-ef7f7e padding radius-big "><input type="text" name="mob_phone" id="mob_phone" maxlength="11" value="<?php echo $output['address']['mob_phone'];?>" class="border-none layout" placeholder=""></div>
        </div>
        <div class="padding-small-top">电话号码<span class="padding-left text-small text-red">格式：*区号-电话号码-分机号*</span>
            <div class="border border-ef7f7e padding radius-big "><input type="text" name="tel_phone" id="tel_phone"  value="<?php echo $output['address']['tel_phone'];?>" class="border-none layout" placeholder=""></div>
        </div>
        <div class="padding-small-top">邮编
            <div class="border border-ef7f7e padding radius-big "><input type="text"  name="zip_code" id="zip_code" value="<?php echo $output['address']['zip_code'];?>" class="border-none layout" placeholder=""></div>
        </div>
        <div class="padding-small-top"><span class="text-red">*</span>所在地区

            <div class="border border-ef7f7e padding radius-big " id="region">
                <input type="hidden" value="<?php echo $output['address']['city_id'];?>" name="city_id" id="city_id">
                <input type="hidden" value="<?php echo $output['address']['area_id'];?>" name="area_id" id="area_id" class="area_ids" />
                <input type="hidden" value="<?php echo $output['address']['area_info'];?>" name="area_info" id="area_info" class="area_names" /><?php if(!empty($output['address']['area_id'])){?>
                    <span><?php echo $output['address']['area_info'];?></span>
                    <input type="button" value="编辑" class="edit_region" />
                    <select style="display:none;"  class="check border-none layout"> </select>
                <?php }else{?>
                    <select   class="check border-none layout"></select>
                <?php }?></div>
        </div>
        <div class="padding-small-top"><span class="text-red">*</span>街道地址
            <div class="border border-ef7f7e padding radius-big "><input type="text" name="address" id="address"  value="<?php echo $output['address']['address'];?>" class="border-none layout"></div>
        </div>
        <div class=" margin "><span class="radius-big layout text-big border-none bg-red text-white padding height text-center" onclick="$('#addr_form').submit()">保存地址</span></div>
    </div>
</form>

<script type="text/javascript">
    $(function(){
        $("#addr_form").find('input:not(:button)').focus(function(){
            $('body,html').animate({'scrollTop':$(this).offset().top-100},100);
        })
        regionInit("region");

        jQuery.validator.addMethod("sel", function(value, element) {
            if(value == ''){
                return false;
            }else{
                var arr = value.split("\t");
                if(arr == '' || arr == null || arr.length < 3){
                    return false;
                }else{
                    return true;
                }
            }
        }, "");
        jQuery.validator.addMethod("mob_rul", function(value, element) {
            return this.optional(element) || /^1[43578]{1}\d{9}$/i.test(value);
        }, "手机号码输入错误");

        /*jQuery.validator.addMethod("tel_rul", function(value, element) {
         return this.optional(element) || /^0\d{2,3}-\d{7,8}(-\d{1,4})?$/i.test(value);
         }, "电话号码输入错误"); */

        $("#addr_form ").validate({
            errorPlacement: function(error, element){
                var error_td = element.parent('div');
                error_td.append(error);
            },
            rules: {
                true_name: {
                    required	: true,
                    minlength 	: 2,
                    maxlength	: 10
                },
                mob_phone: {
                    required	: true,
                    mob_rul 	: true
                },
                area_info: {
                    sel	:	true
                },
                address: {
                    required	:	true,
                }
                /*tel_phone: {
                 required	: true,
                 tel_rul	:	true,
                 },*/
            },
            messages: {
                true_name:{
                    required	:  "收货人不能为空",
                    minlength		: '收货人为2~10字符长度之间',
                    maxlength	: '收货人为2~10字符长度之间'
                },
                mob_phone	: {
                    required 	:	'手机号码不能为空',
                    mob_rul	:	'手机号码输入错误'
                },
                area_info	: {
                    sel 	:	'请选择所在地区'
                },
                address	: {
                    required 	:	'街道地址不能为空'
                }
                /*tel_phone	: {
                 required 	:	'电话号码不能为空',
                 tel_rul	:	'电话号码输入错误',
                 },*/
            },
            submitHandler: function(form){
                $.getJSON("<?php echo SiteUrl;?>/app/index.php",$("form#addr_form").serialize(),function(data){
                    Jump(data);
                });
            }
        });
    });
</script>
<!--添加、修改收货地址E-->


